﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace ExcelSystem.Rules
{
   

    public class DateTimeValidationRule : ValidationRule
    {
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            if (value == null)
                return ValidationResult.ValidResult;
            else
            {
                return DateTime.TryParse((value ?? "").ToString(),
          CultureInfo.CurrentCulture,
          DateTimeStyles.AssumeLocal | DateTimeStyles.AllowWhiteSpaces,
          out _)
          ? ValidationResult.ValidResult
          : new ValidationResult(false, "Invalid date");
            }

          
        }
    }
}
